package com.shrw.duke.serialport.common.enity;

/**
 * Created by rw-duke on 2018/1/18.
 */

public class DevArgEnity extends BaseLabelEnity {
    private final String LENGTH = "001E";
    private String packetsIntervals;//数据包发送间隔
    private String beatPacketsSentIntervals;//心跳包发送间隔
    private String gpsSentIntervals;//GPS发送间隔
    private String filteringModeSetting;//过滤模式设定
    private String filteringTimeSetting;//过滤时间设定
    private String BZS;//蜂鸣器开关
    private String SERBAUD;//串口波特率
    private String replyConfig;//回复配置
    private String rev ="0001020304050607";//保留位

    public String getPacketsIntervals() {
        return packetsIntervals;
    }

    public void setPacketsIntervals(String packetsIntervals) {
        this.packetsIntervals = packetsIntervals;
    }

    public String getBeatPacketsSentIntervals() {
        return beatPacketsSentIntervals;
    }

    public void setBeatPacketsSentIntervals(String beatPacketsSentIntervals) {
        this.beatPacketsSentIntervals = beatPacketsSentIntervals;
    }

    public String getGpsSentIntervals() {
        return gpsSentIntervals;
    }

    public void setGpsSentIntervals(String gpsSentIntervals) {
        this.gpsSentIntervals = gpsSentIntervals;
    }

    public String getFilteringModeSetting() {
        return filteringModeSetting;
    }

    public void setFilteringModeSetting(String filteringModeSetting) {
        this.filteringModeSetting = filteringModeSetting;
    }

    public String getFilteringTimeSetting() {
        return filteringTimeSetting;
    }

    public void setFilteringTimeSetting(String filteringTimeSetting) {
        this.filteringTimeSetting = filteringTimeSetting;
    }

    public String getBZS() {
        return BZS;
    }

    public void setBZS(String BZS) {
        this.BZS = BZS;
    }

    public String getSERBAUD() {
        return SERBAUD;
    }

    public void setSERBAUD(String SERBAUD) {
        this.SERBAUD = SERBAUD;
    }

    public String getReplyConfig() {
        return replyConfig;
    }

    public void setReplyConfig(String replyConfig) {
        this.replyConfig = replyConfig;
    }

    public String getRev() {
        return rev;
    }

    public void setRev(String rev) {
        this.rev = rev;
    }

    @Override
    public void parse(String data) {
        super.parse(data);
//        02030405001E71B8FD431201000A0AFF0000000700000102030405060700
        cmd = "12";
        packetsIntervals = instruction.substring(26, 28);
        beatPacketsSentIntervals = instruction.substring(28, 30);
        gpsSentIntervals = instruction.substring(30, 32);
        filteringModeSetting = instruction.substring(32, 34);
        filteringTimeSetting = instruction.substring(34, 36);
        BZS = instruction.substring(36, 38);
        SERBAUD = instruction.substring(38, 40);
        replyConfig = instruction.substring(40, 42);
//        rev = instruction.substring(42, 58);

    }

    @Override
    public String toString() {
        instruction = new StringBuilder();
        instruction.append(head);
        instruction.append(LENGTH);
        instruction.append(devId);
        instruction.append("12");
        instruction.append(sn);
        instruction.append(encryption);
        instruction.append(packetsIntervals);
        instruction.append(beatPacketsSentIntervals);
        instruction.append(gpsSentIntervals);
        instruction.append(filteringModeSetting);
        instruction.append(filteringTimeSetting);
        instruction.append(BZS);
        instruction.append(SERBAUD);
        instruction.append(replyConfig);
        instruction.append(rev);
        instruction.append(checkSum);

        return instruction.toString();
    }
}
